package com.wetao.lib_common.bean.vo;

public class PictureMore {
    public Float startX_L = 0f;
    public Float startY_L = 0f;
    public Float endX_L = 0f;
    public Float endY_L = 0f;
    public Float startX_R = 0f;
    public Float startY_R = 0f;
    public Float endX_R = 0f;
    public Float endY_R = 0f;
    public boolean isLR = false; //是否是左右分栏

    //步骤一
    public void setTemp1(Float startX, Float startY, Float endX, Float endY, Integer picWidth, Integer picHeight) {
        if(startX == null) {
            startX = 0f;
        }
        if(startY == null) {
            startY = 0f;
        }
        if(endX == null) {
            endX = 0f;
        }
        if(endY == null) {
            endY = 0f;
        }
        if(picWidth == null) {
            picWidth = 0;
        }
        if(picHeight == null) {
            picHeight = 0;
        }

        if(startX.floatValue() > picWidth.floatValue() / 3 || endX.floatValue() < picWidth.floatValue() * 2 / 3) {
            //左右分栏
            isLR = true;

            if(endX.floatValue() < picWidth.floatValue() * 2 / 3) {
                //左栏
                if(startX_L.intValue() == 0) {
                    startX_L = startX.floatValue();
                }
                if(startY_L.intValue() == 0) {
                    startY_L = startY.floatValue();
                }
                if(endX_L.intValue() == 0) {
                    endX_L = endX.floatValue();
                }
                if(endY_L.intValue() == 0) {
                    endY_L = endY.floatValue();
                }

                if(startX.floatValue() < startX_L.floatValue()) {
                    startX_L = startX.floatValue();
                }

                if(startY.floatValue() < startY_L.floatValue()) {
                    startY_L = startY.floatValue();
                }

                if(endX.floatValue() > endX_L.floatValue()) {
                    endX_L = endX.floatValue();
                }

                if(endY.floatValue() > endY_L.floatValue()) {
                    endY_L = endY.floatValue();
                }
            } else if(startX.floatValue() > picWidth.floatValue() / 3) {
                //右栏
                if(startX_R.intValue() == 0) {
                    startX_R = startX.floatValue();
                }
                if(startY_R.intValue() == 0) {
                    startY_R = startY.floatValue();
                }
                if(endX_R.intValue() == 0) {
                    endX_R = endX.floatValue();
                }
                if(endY_R.intValue() == 0) {
                    endY_R = endY.floatValue();
                }

                if(startX.floatValue() < startX_R.floatValue()) {
                    startX_R = startX.floatValue();
                }

                if(startY.floatValue() < startY_R.floatValue()) {
                    startY_R = startY.floatValue();
                }

                if(endX.floatValue() > endX_R.floatValue()) {
                    endX_R = endX.floatValue();
                }

                if(endY.floatValue() > endY_R.floatValue()) {
                    endY_R = endY.floatValue();
                }
            }
        } else {
            isLR = false;
            //上下分栏

            if(startX_L.intValue() == 0) {
                startX_L = startX.floatValue();
            }
            if(startY_L.intValue() == 0) {
                startY_L = startY.floatValue();
            }
            if(endX_L.intValue() == 0) {
                endX_L = endX.floatValue();
            }
            if(endY_L.intValue() == 0) {
                endY_L = endY.floatValue();
            }

            if(startX.floatValue() < startX_L.floatValue()) {
                startX_L = startX.floatValue();
            }

            if(startY.floatValue() < startY_L.floatValue()) {
                startY_L = startY.floatValue();
            }

            if(endX.floatValue() > endX_L.floatValue()) {
                endX_L = endX.floatValue();
            }

            if(endY.floatValue() > endY_L.floatValue()) {
                endY_L = endY.floatValue();
            }

        }
    }

    //步骤二
    public void setTemp2(Integer picWidth, Integer picHeight) {
        if(picWidth == null) {
            picWidth = 0;
        }
        if(picHeight == null) {
            picHeight = 0;
        }
        if(isLR) {

            if(startY_L.floatValue() < picHeight.floatValue() / 10) {
                startY_L = 0f;
            }
            if(endY_L.floatValue() > picHeight.floatValue() * 9 / 10) {
                endY_L = picHeight.floatValue();
            }

            if(startY_R.floatValue() < picHeight.floatValue() / 10) {
                startY_R = 0f;
            }
            if(endY_R.floatValue() > picHeight.floatValue() * 9 / 10) {
                endY_R = picHeight.floatValue();
            }

            startX_L = 0f;
            endX_R = picWidth.floatValue();
        } else {
            if(startY_L.floatValue() < picHeight.floatValue() / 10) {
                startY_L = 0f;
            }
            if(endY_L.floatValue() > picHeight.floatValue() * 9 / 10) {
                endY_L = picHeight.floatValue();
            }
            startX_L = 0f;
            endX_L = picWidth.floatValue();
        }
    }

    @Override
    public String toString() {
        return "PictureMore{" +
                "startX_L=" + startX_L +
                ", startY_L=" + startY_L +
                ", endX_L=" + endX_L +
                ", endY_L=" + endY_L +
                ", startX_R=" + startX_R +
                ", startY_R=" + startY_R +
                ", endX_R=" + endX_R +
                ", endY_R=" + endY_R +
                ", isLR=" + isLR +
                '}';
    }
}
